package com.vhly.ddxdecompiler.dexreader.file.dalv.code;

import com.vhly.ddxdecompiler.dexreader.file.dalv.code.reader.InsnReader;

/**
 * Created by IntelliJ IDEA.
 * User: vhly
 * Date: 2009-10-21
 * Time: 14:14:13
 *
 * @author vhly[FR]
 */
public class Dop {
    private final int opcode;
    private final int family;
    private final InsnReader insnReader;
    private final boolean hasResult;
    private final String name;

    public Dop(int opcode, int family, InsnReader reader, boolean hasResult, String name) {
        if (opcode < -1 || opcode > 255)
            throw new IllegalArgumentException("bogus opcode");
        if (family < -1 || family > 255)
            throw new IllegalArgumentException("bogus family");
        if (reader == null)
            throw new NullPointerException("reader == null");
        if (name == null) {
            throw new NullPointerException("name == null");
        } else {
            this.opcode = opcode;
            this.family = family;
            this.insnReader = reader;
            this.hasResult = hasResult;
            this.name = name;
        }
    }

    public String toString() {
        return name;
    }

    public int getOpcode() {
        return opcode;
    }

    public int getFamily() {
        return family;
    }

    public InsnReader getInsnReader() {
        return insnReader;
    }

    public boolean hasResult() {
        return hasResult;
    }

    public String getName() {
        return name;
    }
}
